package com.thesis.student.controller;

import com.alibaba.fastjson.JSONObject;
import com.thesis.manage.common.utils.Result;
import com.thesis.manage.domain.Student;
import com.thesis.manage.service.GradeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author php
 * @date 2018/4/6
 */
@RestController
@RequestMapping("/grade")
public class GradeController extends BaseController {
    @Resource
    private GradeService gradeService;

    /**
     * 查找自己的成绩
     */
    @GetMapping("/my")
    public Map<String, Object> findByStudentId() {
        return buildMessage(() -> {
            Result result = getUser();
            Student student = JSONObject.parseObject(result.getData().toString(), Student.class);
            return gradeService.findGradeByStudentId(student.getStudentNumber());
        });
    }
}
